<?

/**
* Global processing functions
*
* @author Adesanto Asman
* @version 1.0
* @license Free
* @package CGlobalProcessors
*
*/

class CGlobalProcessors{

  /**
  * First Menu login
  *
  * @param  string    $message      user message
  *
  */
  function procLogin(&$message){

    /**
    * If we have flash message set
    * meaning the login has failed or
    * something happened
    *
    */
    if($message){

      $theLabel = $message;
    }else{

      $theLabel = "Login";
    }

    echo  "<p align='center'><br/><br/><br/><br/><b>.:".$theLabel.":.</b></p>".
        	"<form action=# method=post>".
          " <table border=1 align='center' class='dedeq'>".
          "  	<tr >".
          "		<td ><p>ID   </td><td ><input type=text     name='user' size='20' maxlength='20'> </p></td></tr>".
          "		<tr >".
          "		<td ><p>Pass </td><td ><input type=password name='pass' size='20' maxlength='20'> </p></td></tr>".
          "		</center>".
          "	</table>".
          "	<p align='center'><input type='submit' value='Login' name='continue' align='center'> </p>".
        	"</form>".
        	"</p>";
  }

  /**
  * Re validation form
  *
  * @param  string  $message        user message
  * @param  string  $tgtUrl         target urldecode
  * @param  string  $btnLabel       button label
  * @param  string  $btnName        button name
  * @param  string  $btnValue       button value
  * @param  string  $btnProperties  button properties
  *
  */
  function procChkValidation(&$message,
                             &$tgtUrl,
                             &$btnLabel,
                             &$btnName,
                             &$btnValue,
                             &$btnProperties){

    echo  "<br/><br/><br/><br/>\n".

  	      "<p align='center'><b>.:".$message.":.</b></p>\n".

  	      "<form action=".$tgtUrl." method=post>\n".
  		    "<table border=1 align='center' class='dedeq'>\n".
  		    "<tr>\n".

  				  "<td><p>ID      </td><td><input type=text     name='reauth_user' size='20'> </p></td>\n".

  				"</tr>\n".
  				"<tr>\n".

  					"<td><p>Pass    </td><td><input type=password name='reauth_pass' size='20'> </p></td>\n".

  				"</tr>\n".
  				"</table>\n".

  			  "<p align='center'><button name='".$btnName."' value='".$btnValue."' type='submit' ".$btnProperties.">".$btnLabel."</button></p>\n".
  				"</form>";

  }

  function formOkValidated(&$message,
  				                 &$tgtUrl,
  				                 &$btnLabel,
  				                 &$btnName,
  				                 &$btnValue,
  				                 &$btnProperties){

    echo  "<br/><br/><br/><br/><br/><br/>\n".

  			  "<p align='center'><b>.:".$message.":.</b></p>\n".

  				"<form action=".$tgtUrl." method=POST></p>\n".

  				"<p align='center'><button name='".$btnName."' value='".$btnValue."' type='submit' ".$btnProperties.">".$btnLabel."</button></p>\n".
  				"</form> ";
  }

  /**
  * Create custom serialization
  *
  * @param  string    $userId
  * @param  string    $srcValues
  *
  */
  function customSerialize(&$userId, &$srcValues){

    $srcDbHdr = "USER_TEMP_VARS_HDR";
    $srcDbDtl = "USER_TEMP_VARS_DTL";

    $COracle = new oracleDb;

    $COracle->init($_SESSION["ORCL"],
                   $_SESSION["OPASS"],
                   $_SESSION["SID"]);

    if($COracle->connect()){

      initSerialize($COracle,
                    $userId,
                    $srcValues,
                    $srcDbHdr,
                    $srcDbDtl);

    }else{

      usrDie("Error: Oracle connection failed, serializing failed");

    }
  }

  /**
  * Create custom serialization
  *
  * @param  string    $userId
  * @param  string    $srcValues
  * @param  string    $theResult
  *
  */
  function customUnserialize(&$userId,
                             &$srcValues,
                             &$theResult){

    $srcDbHdr = "USER_TEMP_VARS_HDR";
    $srcDbDtl = "USER_TEMP_VARS_DTL";

    $COracle = new oracleDb;

    $COracle->init($_SESSION["ORCL"],
                   $_SESSION["OPASS"],
                   $_SESSION["SID"]);

    if($COracle->connect()){

      fetchUnserialize($COracle,
                       $userId,
                       $srcValues,
                       $srcDbHdr,
                       $srcDbDtl,
                       $theResult);

    }else{

      usrDie("Error: Oracle connection failed, serializing failed");

    }
  }

  /**
  * init all additional variables
  *
  * @param void
  *
  */
  function procVarsAdditional(){

    $srcDbMstLevelD = "MST_LEVELD";

    $Db = new Oracle;

    $Db->init($_SESSION["ORCL"],
              $_SESSION["OPASS"],
              $_SESSION["SID"],
              _NO_COMMENT);

    if($Db->connect()){

    	GlobalFetchers::fetchSelLevelD($Db,
                                     $srcDbMstLevelD,
                                     $thisLevelD);

      $_SESSION["curLevelD"] = $thisLevelD;

    	$_SESSION["sysPeriode"]= date("m-Y");

      $Db->dc();
    }else{

      usrErr("Oracle Connection Failed");
    }
  }
}

?>